package com.gt.quality.apim.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gt.quality.apim.domain.GptApplyManage;
import com.gt.quality.apim.service.GptApplyManageService;
import com.gt.quality.config.SpringBeanUtil;
import com.gt.quality.system.mapper.GptApplyManageMapper;
import com.gt.quality.base.pojo.BaseLimitRequest;
import com.gt.quality.system.service.GTBaseService;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;

import java.util.List;

/**
 * 应用数据源关联表(GptApplyManage)表服务实现类
 *
 * @author makejava
 * @since 2026-12-03 17:00:38
 */
@Service("gptApplyManageService")
public class GptApplyManageServiceImpl extends ServiceImpl<GptApplyManageMapper, GptApplyManage> implements GTBaseService<GptApplyManage>, GptApplyManageService {


    private GptApplyManageMapper gptApplyManageMapper;

    @Autowired
    public void setGptApplyManageMapper(GptApplyManageMapper gptApplyManageMapper) {
        this.gptApplyManageMapper = gptApplyManageMapper;
    }

    /**
     * 往上传递 SqlSessionFactory
     * @return SqlSessionFactory
     */
    @Override
    public SqlSessionFactory getSqlSessionFactory() {
        return super.getSqlSessionFactory();
    }

    /**
     * 往上传递 Mapper
     * @return Mapper
     */
    @Override
    public Class<?> getThisMapperClass() {
        return GptApplyManageMapper.class;
    }

    /**
     * 往上传递 Transaction
     * @return Transaction
     */
    @Override
    public TransactionTemplate getSpringTx() {
        return SpringBeanUtil.getBean(TransactionTemplate.class);
    }


    /**
     * Description:  分页查询
     *
     * @param limitRequest 分页查询参数
     * @author: makejava
     * @date: 2026-12-03 17:00:38
     * @return:com.baomidou.mybatisplus.core.metadata.IPage
     */
    @Override
    public IPage<GptApplyManage> queryLimitPage(BaseLimitRequest<GptApplyManage> limitRequest) {
        GptApplyManage requestBody = limitRequest.getRequestBody();
        IPage<GptApplyManage> page = getByPageParam(limitRequest);
        com.alibaba.fastjson2.JSONObject thisObj = JSONObject.from(requestBody);
        QueryWrapper<GptApplyManage> queryWrapper = queryWrapperBuilder(thisObj, limitRequest);
        return gptApplyManageMapper.selectPage(page, queryWrapper);
    }

    /**
     * Description:  批量新增优化版
     *
     * @param entityList entityList
     * @author: makejava
     * @date: 2026-12-03 17:00:38

     */
    @Override
    public Integer saveBatchByEasyBaseMapper(List<GptApplyManage> entityList) {
        for (GptApplyManage gptApplyManage : entityList) {
            gptApplyManageMapper.insert(gptApplyManage);
        }
        return entityList.size();
    }

}


